/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewGame.java
 *
 * Created on 18.4.2011, 10:41:36
 */

package src.clovece;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

/**
 *
 * @author Thomas
 */
public class NewGameDialog extends javax.swing.JDialog {
    private Boolean okClicked = false;
    private int gameBoardSize = 36;
    private int numberOfPlayers = 2;

    /** Creates new form NewGame */
    public NewGameDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        GameBoardSizeLabel = new javax.swing.JLabel();
        NumberOfPlayersLabel = new javax.swing.JLabel();
        GameBoardSizeComboBox = new javax.swing.JComboBox();
        NumberOfPlayersComboBox = new javax.swing.JComboBox();
        OkButton = new javax.swing.JToggleButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        GameBoardSizeLabel.setText("Game board size");

        NumberOfPlayersLabel.setText("Number of players");

        GameBoardSizeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "36", "48", "84" }));
        GameBoardSizeComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GameBoardSizeComboBoxActionPerformed(evt);
            }
        });

        NumberOfPlayersComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2", "3", "4" }));
        NumberOfPlayersComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NumberOfPlayersComboBoxActionPerformed(evt);
            }
        });

        OkButton.setText("OK");
        OkButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                OkButtonMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(GameBoardSizeLabel)
                    .addComponent(NumberOfPlayersLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(NumberOfPlayersComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(GameBoardSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(68, 68, 68)
                .addComponent(OkButton)
                .addContainerGap(75, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(GameBoardSizeLabel)
                    .addComponent(GameBoardSizeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(NumberOfPlayersLabel)
                    .addComponent(NumberOfPlayersComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(OkButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void GameBoardSizeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GameBoardSizeComboBoxActionPerformed
        JComboBox cb = (JComboBox)evt.getSource();
	String gameDeskSize = (String)cb.getSelectedItem();
	this.gameBoardSize = Integer.parseInt(gameDeskSize);
        System.out.println("Velkost plochy:" + this.gameBoardSize);
    }//GEN-LAST:event_GameBoardSizeComboBoxActionPerformed

    private void NumberOfPlayersComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NumberOfPlayersComboBoxActionPerformed
        JComboBox cb = (JComboBox)evt.getSource();
	String numberOfPlayers = (String)cb.getSelectedItem();
	this.numberOfPlayers = Integer.parseInt(numberOfPlayers);
        System.out.println("Pocet hracov:" + this.numberOfPlayers);
    }//GEN-LAST:event_NumberOfPlayersComboBoxActionPerformed

    private void OkButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_OkButtonMouseClicked
        this.okClicked = true;
        this.setVisible(false);
    }//GEN-LAST:event_OkButtonMouseClicked

    public int returnGameBoardSize() {
            return this.gameBoardSize;
    }

    public int returnNumberOfPlayers() {
            return this.numberOfPlayers;
    }

    public Boolean returnOkClicked() {
            return this.okClicked;
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                NewGameDialog dialog = new NewGameDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox GameBoardSizeComboBox;
    private javax.swing.JLabel GameBoardSizeLabel;
    private javax.swing.JComboBox NumberOfPlayersComboBox;
    private javax.swing.JLabel NumberOfPlayersLabel;
    private javax.swing.JToggleButton OkButton;
    // End of variables declaration//GEN-END:variables

}
